import request from '../../../../../public/js/common/api/api.js';
const SubDataUrl = Utils.CurDomain.SubDataUrl
const FeedstockUrl = Utils.CurDomain.FeedstockUrl
const AccountUrl = Utils.CurDomain.AccountUrl;
const SysAuthUrl = Utils.CurDomain.SysAuthUrl;

const configuration = {
    contentType: 'application/json',
    dataType: 'json',
    async: true,
    dataFilter(data, type) {
        return data;
    }
}

/**
 * @file神农招聘API
 */
export default class RowMaterialAPI {
    /**
    * 根据JWT获取人员信息
    * @param id
    * @returns 
    */
    static getUserInfo() {
        return request.get(`${SysAuthUrl}/account/u`);
    }
    /**
    * 获取登录用户拥有组织
    * @param id
    * @returns 
    */
    // 查信息询登录用户拥有的组织
    static postUserOrgsList() {
        return request.get(`${AccountUrl}/accounts/orgs`);
    }

    /**
    * 获取行政区划列表信息
    * @param {*} id 
    * @returns 
    */
    static getDistrictsType(type, id) {
        const param = Utils.IsNotNull(id) ? `&pid=${id}` : '&pid=e8wa';
        return request.get(`${SubDataUrl}/districts/q?l=${type}${param}`);
    }
    /**
   * 采购合同列表
   * @param id
   * @returns 
   */
    static purContracts(data) {
        let { SearchInfo, PageIndex, PageSize, Sort, BillStatus } = data;
        const searchInfoParam = Utils.IsNotNull(SearchInfo) ? `&SearchInfo=${SearchInfo}` : '';

        return request.get(`${FeedstockUrl}/purcontracts?PageIndex=${PageIndex}&BillStatus=${BillStatus}${searchInfoParam}`);
    }
    /**
    * 饲料原料
    * @param id
    * @returns 
    */
    static getrowMaterial() {
        return request.get(`${FeedstockUrl}/inventoryrecords/materials`);
    }
    /**
    * 原料库存新增
    * @param id
    * @returns 
    */
    static addRowMaterial(data) {
        return request.post(`${FeedstockUrl}/inventoryrecords`, data, true, configuration);
    }

}